package HomeWork;

import java.io.File;
import java.io.FileInputStream;


public class Deomo01 {
    public static void main(String[] args) {
        File file=new File("D:\\file01.txt");
        write1(file);
        write2(file);
    }
    static void write1(File file){
        try(FileInputStream ips=new FileInputStream(file)){
            int d;
            if((d=ips.read())!=-1){
                System.out.println((char)d);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    static void write2(File file){
        try(FileInputStream ips=new FileInputStream(file)){
            int d;
            byte[] bytes=new byte[3];
            if((d=ips.read(bytes))!=-1){
                System.out.println(new String(bytes,0,d));
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }

}
